import React from 'react'
import "../css/Inputbox.css"
import eventEmitter from "../event"

class Inputbox extends React.Component{
    constructor(){
        super()
        
    }
  render(){
      return(
          <div className="Inputboxclass">
              <input type="text" ref="input"></input>
              <button onClick={()=>{
                  let value=this.refs.input.value
                //   alert(value)
                if(value.length===0){
                    alert("输入内容不能为空")
                    return;
                }
                var date=new Date()
                var datestr=`${date.getFullYear()}年${date.getMonth()+1}月${date.getDay()+1}日${date.getHours()}时${date.getMinutes()}分${date.getSeconds()}秒`
                var message={
                    content:value,
                    date:datestr
                }

                eventEmitter.emit("sendMessage",message)
              }}>提交</button>
          </div>
      )
  }

}  

export default Inputbox